<template>
<view class="container">
	<block v-if="isload">
		<view class="ordertop"  :style="{background:t('color1')}" >
		
		</view>
		<view class="product">
			<view class="info flex">
				<text class="t1">订单编号：</text>
				<text class="t2" user-select="true" selectable="true">{{detail.ordernum}}</text>
			</view>
			<view class="content">
				<view class="flex">
					<view @tap="goto" :data-url="'product?id=' + detail.proid">
						<image :src="detail.propic"></image>
					</view>
					<view class="detail">
						<text class="t1">{{detail.proname}}</text>
						<view class="t3"><text class="t2">{{detail.ggname}} </text><text class="x2">×{{detail.num}}</text></view>
					</view>
				</view>
				<view class="item">
					<text class="t1">商品数量</text>
					<text class="t2" user-select="true" selectable="true">{{detail.num}}</text>
				</view>
				<view class="item">
					<text class="t1">实付金额</text>
					<text class="t2 red">￥{{detail.product_price}}</text>
				</view>
				<view class="item2">
					<view><text class="t1">寄卖规则</text></view>
					<view class="rule">{{shopset.rule}}</view>
					
				</view>
			
			</view>
			<view class="orderinfo">
				<view class="item">
					<text class="t1">寄售状态</text>
					<text class="t2 red" user-select="true" v-if="detail.status==7"  selectable="true">寄售审核中</text>
				</view>
			</view>
		
			<view class="op" v-if="detail.status==1">
				<view class="tobuy flex-x-center flex-y-center"  :style="{background:t('color1')}"   @tap="jishou" :data-id="detail.id" >申请寄卖</view>
			</view>
		</view>
	</block>
	<loading v-if="loading"></loading>
	<dp-tabbar :opt="opt"></dp-tabbar>
	<popmsg ref="popmsg"></popmsg>
</view>
</template>

<script>
var app = getApp();

export default {
  data() {
    return {
			opt:{},
			loading:false,
      isload: false,
			menuindex:-1,
			
			pre_url:app.globalData.pre_url,
			textset:{},
			detail:{},
			team:{},
			storeinfo:{},
			shopset:{},
			invoice:0
    }
  },

  onLoad: function (opt) {
		this.opt = app.getopts(opt);
		this.getdata();
  },
	onPullDownRefresh: function () {
		this.getdata();
	},
  methods: {
		getdata: function (option) {
			var that = this;
			that.loading = true;
			app.get('ApiTglCollage/orderdetail', {id: that.opt.id}, function (res) {
				that.loading = false;
				that.detail = res.detail;
				that.team = res.team;
				that.storeinfo = res.storeinfo;
				that.shopset = res.shopset;
				that.textset = app.globalData.textset;
				that.invoice = res.invoice;
				that.loaded();
			});
		},
    todel: function (e) {
      var that = this;
      var orderid = e.currentTarget.dataset.id;
      app.confirm('确定要删除该订单吗?', function () {
				app.showLoading('删除中');
        app.post('ApiTglCollage/delOrder', {orderid: orderid}, function (data) {
					app.showLoading(false);
          app.success(data.msg);
          setTimeout(function () {
            that.getdata();
          }, 1000);
        });
      });
    },
    toclose: function (e) {
      var that = this;
      var orderid = e.currentTarget.dataset.id;
      app.confirm('确定要关闭该订单吗?', function () {
				app.showLoading('提交中');
        app.post('ApiTglCollage/closeOrder', {orderid: orderid}, function (data) {
					app.showLoading(false);
          app.success(data.msg);
          setTimeout(function () {
            that.getdata();
          }, 1000);
        });
      });
    },
    orderCollect: function (e) {
      var that = this;
      var orderid = e.currentTarget.dataset.id;
      app.confirm('确定要收货吗?', function () {
				app.showLoading('提交中');
        app.post('ApiTglCollage/orderCollect', {orderid: orderid}, function (data) {
					app.showLoading(false);
          app.success(data.msg);
          setTimeout(function () {
            that.getdata();
          }, 1000);
        });
      });
    },
		showhxqr:function(){
			this.$refs.dialogHxqr.open();
		},
		closeHxqr:function(){
			this.$refs.dialogHxqr.close();
		},
		openMendian: function(e) {
			var storeinfo = e.currentTarget.dataset.storeinfo;
			app.goto('/pagesZ/shop/mendian?id=' + storeinfo.id);
		},
		jishou: function (e) {
		  var that = this;
		  var orderid = e.currentTarget.dataset.id;
		  app.confirm('确定要寄售该商品吗?', function () {
				app.showLoading('寄售中');
		    app.post('ApiTglCollage/apply_sale', {orderid: orderid}, function (data) {
					app.showLoading(false);
		      app.success(data.msg);
		      setTimeout(function () {
		        that.getdata();
		      }, 1000);
		    });
		  });
		},
  }
};
</script>
<style>
.ordertop{width:100%;height:220rpx;padding:50rpx 0 0 70rpx; position: relative;}
.ordertop .f1{color:#fff}
.ordertop .f1 .t1{font-size:32rpx;height:60rpx;line-height:60rpx}
.ordertop .f1 .t2{font-size:24rpx}

.product .info{flex:1;display:flex;line-height: 100rpx; border-bottom: 1px solid #EFEFEF;}
.product .info .t1{font-size:26rpx;color:#BBBBBB}
.product .info .t2{font-size:26rpx;color:#222}

.product{width:94%;margin:0 3%;border-radius:8rpx;margin-top:16rpx;padding: 14rpx 3%;background: #FFF; position: absolute;top:5%}
.product .content{position:relative;width: 100%; padding:16rpx 0px;border-bottom: 1px #e5e5e5 dashed;position:relative}
.product .content:last-child{ border-bottom: 0; }
.product .content image{ width: 140rpx; height: 140rpx;}
.product .content .detail{display:flex;flex-direction:column;margin-left:14rpx;flex:1}
.product .content .detail .t1{height:80rpx;line-height:40rpx;color: #000;}
.product .content .detail .t2{height: 46rpx;line-height: 46rpx;color: #999;overflow: hidden;font-size: 26rpx;}
.product .content .detail .t3{display:flex;height:40rpx;line-height:40rpx;color: #ff4246; justify-content: space-between;}
.product .content .detail .x1{ flex:1}
.product .content .detail .x2{ width:100rpx;font-size:32rpx;text-align:right;margin-right:8rpx}
.product .content .comment{position:absolute;top:64rpx;right:10rpx;border: 1px #ffc702 solid; border-radius:10rpx;background:#fff; color: #ffc702;  padding: 0 10rpx; height: 46rpx; line-height: 46rpx;}
.content .item{ display:flex;width:100%;padding:10rpx 0; margin-top: 20rpx;}
.content .item .t1{width:200rpx;}
.content .item .t2{flex:1;text-align:right}
.content .item .red{color:red}
.content .item2{ padding: 20rpx 0;} 
.content .rule{ margin-top: 20rpx;color:#AAAAAA;font-size: 22rpx;line-height: 40rpx;}
	
.orderinfo{width:100%;border-radius:8rpx;margin-top:16rpx;background: #FFF;}
.orderinfo .item{display:flex;width:100%;padding:20rpx 0;border-bottom:1px dashed #ededed;}
.orderinfo .item:last-child{ border-bottom: 0;}
.orderinfo .item .t1{}
.orderinfo .item .t2{flex:1;text-align:right}
.orderinfo .item .red{color:red}

.bottom{ width: 100%;height:92rpx;padding: 0 20rpx;background: #fff; position: fixed; bottom: 0px; left: 0px;display:flex;justify-content:flex-end;align-items:center;}
.btn1{margin-left:20rpx;width:160rpx;height:60rpx;line-height:60rpx;color:#fff;background:#FB4343;border-radius:3px;text-align:center}
.btn2{margin-left:20rpx;width:160rpx;height:60rpx;line-height:60rpx;color:#333;background:#fff;border:1px solid #cdcdcd;border-radius:3px;text-align:center}
.btn3{position:absolute;top:60rpx;right:10rpx;font-size:24rpx;width:120rpx;height:50rpx;line-height:50rpx;color:#333;background:#fff;border:1px solid #cdcdcd;border-radius:3px;text-align:center}

.hxqrbox{background:#fff;padding:50rpx;position:relative;border-radius:20rpx}
.hxqrbox .img{width:400rpx;height:400rpx}
.hxqrbox .txt{color:#666;margin-top:20rpx;font-size:26rpx;text-align:center}
.hxqrbox .close{width:50rpx;height:50rpx;position:absolute;bottom:-100rpx;left:50%;margin-left:-25rpx;border:1px solid rgba(255,255,255,0.5);border-radius:50%;padding:8rpx}
.op .tobuy{height: 72rpx; border-radius: 8rpx; width:90%;line-height: 72rpx;color: #fff; border: none;font-size:28rpx;font-weight:bold; position: fixed; bottom:10rpx;}

.status{ color: red; margin-top: 20rpx;}
</style>